package com.yingma.system.service.impl;

import com.yingma.system.dao.JcSysUserDao;
import com.yingma.system.entity.JcSysUser;
import com.yingma.system.service.JcSysUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (JcSysUser)表服务实现类
 *
 * @author makejava
 * @since 2020-03-03 16:03:25
 */
@Service("jcSysUserService")
public class JcSysUserServiceImpl implements JcSysUserService {
    @Resource
    private JcSysUserDao jcSysUserDao;

    /**
     * 登陆
     * @return
     */
    public List<JcSysUser> login(String name, String password) {
        JcSysUser jcSysUsers = new JcSysUser();
        jcSysUsers.setName(name);
        jcSysUsers.setPassword(password);
        return jcSysUserDao.queryAll(jcSysUsers);
    }



    /**
     * 根据 code 查询用户
     * @param code 主键
     * @return
     */
    @Override
    public JcSysUser queryBycode(String code) {
        return jcSysUserDao.queryBycode(code);
    }


    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<JcSysUser> queryAllByLimit(int offset, int limit) {
        return this.jcSysUserDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param jcSysUser 实例对象
     * @return 实例对象
     */
    @Override
    public JcSysUser insert(JcSysUser jcSysUser) {
        this.jcSysUserDao.insert(jcSysUser);
        return jcSysUser;
    }



    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id) {
        return this.jcSysUserDao.deleteById(id) > 0;
    }
}